package org.common.vo;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class ResponseReturn<T> {
	private String message;
    private T data;
    private boolean success;
    
    public ResponseReturn() {
    }
    
    private ResponseReturn(final String message, final T data, final boolean success) {
        this.message = message;
        this.data = data;
        this.success = success;
    }
    
    public static <T> ResponseReturn<T> successful() {
        return getResponseReturn("操作成功~", (T)null, true);
    }
    
    public static <T> ResponseReturn<T> successful(final String message) {
        return getResponseReturn(message, (T)null, true);
    }
    
    public static <T> ResponseReturn<T> successful(final T data) {
        return getResponseReturn("操作成功~", data, true);
    }
    
    public static <T> ResponseReturn<T> successful(final String message, final T data) {
        return getResponseReturn(message, data, true);
    }
    
    public static <T> ResponseReturn<T> error() {
        return getResponseReturn("操作失败~", (T)null, false);
    }
    
    public static <T> ResponseReturn<T> error(final String message) {
        return getResponseReturn(message, (T)null, false);
    }
    
    private static <T> ResponseReturn<T> getResponseReturn(final String string, final T object, final boolean b) {
        return new ResponseReturn<T>(string, object, b);
    }
}
